<?php
/**
 * 登录表单验证
 *
 * @author: yanxs <541139655@qq.com>
 * @version: 1.0
 * @date: 2021/4/1
 */

namespace App\Http\Requests\Backend;

use App\Http\Requests\BaseRequest;

class LoginRequest extends BaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * 表单验证.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'username' => 'required|string|max:50',
            'password' => 'required|string|max:50|min:6',
            'captcha' => 'sometimes|required|string|max:10',
        ];
    }

    public function messages(){
        return [
            'username.required' => '账号不能为空！',
            'password.required' => '密码不能为空！',
            'username.max'      => '英文长度须小于50，中文须小于15!',
            'password.min'      => '密码长度须超过6位',
        ];
    }
}